<?php

namespace app\agent\controller;

use app\model\AgentMini;
use app\common\controller\Adminbase;
use app\service\AgentService;

class MiniSetting extends Adminbase
{

    public function form()
    {
        $model = 'AgentMini';
        $agent = AgentService::getAgentInfo(UID);
        $info  = AgentMini::where('agent_id', $agent['id'])->find();
        if (empty($info)) {
            $info = [
                'agent_id' => $agent['id'],
            ];
            $id = (new AgentMini())->insertGetId($info);
        } else {
            $id = $info['id'];
        }
        $this->assign('id', $id);
        $this->assign('action', 2);

        $builder = new \app\common\controller\FormBuilder();
        $builder
            ->setModel($model)
            ->setSuccessUrl('form')
            ->addFormItem('agent_id', 'hidden', '合作商ID')
//            ->addFormItem('name', 'text', '公众号名称')
            ->addFormItem('official_qrcode', 'image', '公众号二维码')
            ->addFormItem('kefu_qrcode', 'image', '客服二维码')
            ->addFormItem('group_qrcode', 'image', '推客群二维码')
            ->setFormData($info)
            ->returnForm();

        $this->assign('is_verify', 0);
        $this->assign('module', 'app');
        return $this->fetch('admin@common/form');
    }

}
